package org.ala.tiktools.rpc.msg;

import java.io.Serializable;

/**
 * @author ala
 * @date 2025-04-04 17:50
 */
@SuppressWarnings("rawtypes")
public class RpcMsg<C extends RpcMsg> implements Serializable {
    public final static long serialVersionUID = 1;


    /**
     *  消息头
     */
    protected RpcMsgHead head;
    /**
     * 	已经序列化好的消息体
     */
    protected byte[] bodyBytes;
    

    public RpcMsgHead getHead() {
        return head;
    }

    public void setHead(RpcMsgHead head) {
        this.head = head;
    }

    @SuppressWarnings("unchecked")
	public C head(RpcMsgHead head) {
        setHead(head);
        return (C) this;
    }

	public byte[] getBodyBytes() {
		return bodyBytes;
	}

	public void setBodyBytes(byte[] bodyBytes) {
		this.bodyBytes = bodyBytes;
		head.len = bodyBytes.length;
	}
	
	@SuppressWarnings("unchecked")
	public C bodyBytes(byte[] bodyBytes) {
		setBodyBytes(bodyBytes);
		return (C) this;
	}

}
